<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>文章列表--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form" style="width: 100%" id="dataFrm">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">客户编号</label>
            <div class="layui-input-inline">
                <input type="text" name="custNo" lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">客户名称</label>
            <div class="layui-input-inline">
                <input type="text" name="custName" lay-verify="required"   autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">客户地区</label>
            <div class="layui-input-block">
                <select id="customerAre" name="custRegion" class="customerGrade" lay-filter="customerAre">
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">客户经理</label>
            <div class="layui-input-block">
                <select id="custManager" name="custManagerName" class="custManagerGrade" lay-filter="custManager">
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">客户等级</label>
            <div class="layui-input-block">
                <select id="customerGrades" name="custLevel" class="customerrGrade" lay-filter="customerGrades">
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">客户满意度</label>
            <div class="layui-input-inline">
                <select name="custSatisfy" lay-verify="required" lay-search="">
                    <option value="">请选择</option>
                    <option value="1">@</option>
                    <option value="2">@@</option>
                    <option value="3">@@@</option>
                    <option value="4">@@@@</option>
                    <option value="5">@@@@@</option>
                </select><div class="layui-form-select"><div class="layui-select-title"><input type="text" placeholder="直接选择或搜索选择" value="" class="layui-input"><i class="layui-edge"></i></div><dl class="layui-anim layui-anim-upbit"><dd lay-value="" class="layui-select-tips">直接选择或搜索选择</dd><dd lay-value="1" class="">layer</dd><dd lay-value="2" class="">form</dd><dd lay-value="3" class="">layim</dd><dd lay-value="4" class="">element</dd><dd lay-value="5" class="">laytpl</dd><dd lay-value="6" class="">upload</dd><dd lay-value="7" class="">laydate</dd><dd lay-value="8" class="">laypage</dd><dd lay-value="9" class="">flow</dd><dd lay-value="10" class="">util</dd><dd lay-value="11" class="">code</dd><dd lay-value="12" class="">tree</dd><dd lay-value="13" class="">layedit</dd><dd lay-value="14" class="">nav</dd><dd lay-value="15" class="">tab</dd><dd lay-value="16" class="">table</dd><dd lay-value="17" class="">select</dd><dd lay-value="18" class="">checkbox</dd><dd lay-value="19" class="">switch</dd><dd lay-value="20" class="">radio</dd></dl></div>
            </div>
        </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">客户信誉度</label>
            <div class="layui-input-inline">
                <select name="custCredit" lay-verify="required" lay-search="">
                    <option value="">请选择</option>
                    <option value="1">@</option>
                    <option value="2">@@</option>
                    <option value="3">@@@</option>
                    <option value="4">@@@@</option>
                    <option value="5">@@@@@</option>
                </select><div class="layui-form-select"><div class="layui-select-title"><input type="text" placeholder="直接选择或搜索选择" value="" class="layui-input"><i class="layui-edge"></i></div><dl class="layui-anim layui-anim-upbit"><dd lay-value="" class="layui-select-tips">直接选择或搜索选择</dd><dd lay-value="1" class="">layer</dd><dd lay-value="2" class="">form</dd><dd lay-value="3" class="">layim</dd><dd lay-value="4" class="">element</dd><dd lay-value="5" class="">laytpl</dd><dd lay-value="6" class="">upload</dd><dd lay-value="7" class="">laydate</dd><dd lay-value="8" class="">laypage</dd><dd lay-value="9" class="">flow</dd><dd lay-value="10" class="">util</dd><dd lay-value="11" class="">code</dd><dd lay-value="12" class="">tree</dd><dd lay-value="13" class="">layedit</dd><dd lay-value="14" class="">nav</dd><dd lay-value="15" class="">tab</dd><dd lay-value="16" class="">table</dd><dd lay-value="17" class="">select</dd><dd lay-value="18" class="">checkbox</dd><dd lay-value="19" class="">switch</dd><dd lay-value="20" class="">radio</dd></dl></div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">客户地址</label>
            <div class="layui-input-inline">
                <input type="text" name="custAddress" lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">客户邮编</label>
            <div class="layui-input-inline">
                <input type="text" name="custZip" lay-verify="required"   autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">客户传真</label>
            <div class="layui-input-inline">
                <input type="text" name="custFax" lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">办公室电话</label>
            <div class="layui-input-inline">
                <input type="text" name="custTelephone" lay-verify="required"   autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">网址:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input realname" name="custWebsite" lay-verify="required" placeholder="请输入姓名">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">营业执照编号</label>
            <div class="layui-input-inline">
                <input type="text" name="custLicencNo" lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">客户法人</label>
            <div class="layui-input-inline">
                <input type="text" name="custCorporation" lay-verify="required"   autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">注册资金</label>
            <div class="layui-input-inline">
                <input type="text" name="custRegisteredCapital" lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">年营业额</label>
            <div class="layui-input-inline">
                <input type="text" name="custTurnover" lay-verify="required"   autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">开户银行</label>
            <div class="layui-input-inline">
                <input type="text" name="custBank" lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">银行账号</label>
            <div class="layui-input-inline">
                <input type="text" name="custBankAccount" lay-verify="required"   autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">地税登记号</label>
            <div class="layui-input-inline">
                <input type="text" name="custLocalTaxNo" lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">国税登记号</label>
            <div class="layui-input-inline">
                <input type="text" name="custNationalTaxNo" lay-verify="required"   autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">客户标识</label>
        <div class="layui-input-block available">
            <input type="radio" name="custFlag" value="1" title="启用" checked>
            <input type="radio" name="custFlag" value="0" title="禁用">
        </div>
    </div>


    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="addCustomer">立即添加</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script th:inline="none">
    layui.use(['form','layer','laydate','table','laytpl','upload'],function() {
        var form = layui.form
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table,
            upload=layui.upload;

        //     //生日框的时间插件绑定
        //     laydate.render({
        //         elem:".birthday"
        //     });
        //     //上传图片
        // //执行实例
        // var uploadInst = upload.render({
        //     elem: '#test1' //绑定元素
        //     ,url: '/uploadImage2.do/' //上传接口,
        //     ,field:"headImage" //指定文件域名
        //     ,done: function(res){
        //         layer.msg(res.msg);
        //         $("#himg").val(res.data);
        //     }
        //     ,error: function(){
        //         //请求异常回调
        //     }
        //     , before:function (res) {
        //         //上传之前预读本地文件示例
        //         res.preview(function (index,file,result) {
        //             $("#demo1").attr("src",result);
        //         })
        //     }
        // });

        //请求获取数据
        //动态绑定下拉菜单的数据
        var html;
        $.ajax({
            url:'/ares/list.do',
            success:function (data) {
                html += "<option value=''>------------请选择------------</option>"
                for (i = 0; i < data.length; i++) {
                    html += ("<option value='" + data[i].basiValue + "'>" + data[i].basiItem + "</option>")
                }
                $("#customerAre").append(html);
                form.render('select');
            }
        });

        var html1;
        $.ajax({
            url:'/grades/list.do',
            success:function (data) {
                html1 += "<option value=''>------------请选择------------</option>"
                for (i = 0; i < data.length; i++) {
                    html1 += ("<option value='" + data[i].basiValue + "'>" + data[i].basiItem + "</option>")
                }
                $("#customerGrades").append(html1);
                form.render('select');
            }
        });

        var html2;
        $.ajax({
            url:'users/customerManager.do',
            success:function (data) {
                html2 += "<option value=''>------------请选择------------</option>"
                for (i = 0; i < data.length; i++) {
                    html2 += ("<option value='" + data[i].id + "'>" + data[i].realname  + "</option>")
                }
                $("#custManager").append(html2);
                form.render('select');
            }
        });


        form.on("submit(addCustomer)",function (data) {
            //var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            //实际使用时的提交数据
            var params=$("#dataFrm").serialize();
            console.log(params);
            $.post("customers.do",params,function (res) {
                console.log(res.code);
                if(res.code==2001){
                    //top.layer.close(index);
                    top.layer.msg(res.msg);
                    var index1=parent.layer.getFrameIndex(window.name)
                    parent.layer.close(index1);
                    parent.location.reload();
                }else if(res.code=-1004){
                    layer.msg(res.msg);
                }else if(res.code=-2001){
                    layer.msg(res.msg);
                }
            },"json");
            return false;
        });
    });
</script>
</body>
</html>